Skip to content

Conversation

@msooseth
Copy link
Collaborator

@msooseth msooseth commented Feb 10, 2026

Description

Adds two new rewrites:

  • Mul (Lit 0xFF..FF) x = -x
  • Add (Lit 1) (Xor (Lit 0xFF..FF) x) = -x
  • Enable NOT concretization, which was accidentally not enabled

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

@msooseth msooseth marked this pull request as ready for review February 10, 2026 13:08
@msooseth msooseth requested a review from blishko February 10, 2026 13:09
Copy link
Collaborator

@blishko blishko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

msooseth and others added 2 commits February 10, 2026 14:40
Co-authored-by: blishko <blishko@argot.org>
Co-authored-by: blishko <blishko@argot.org>
src/EVM/Expr.hs Outdated

-- Negation: ~x + 1 = 0 - x (two's complement)
go (Add (Lit 1) (Not b)) = Sub (Lit 0) b
go (Xor (Lit a) b) | a == maxLit = Not b
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the Xor rule to the Xor section below.
Also, not sure what will happen if b is a literal. I guess the result should actually be Expr.not b? WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm moving it lower down. It'll make it into Not b which SHOULD call EVM.Expr.not to simplify concrete values but that's missing! WOW. Oooooops. We literally never simplify negated concrete values :S Adding that into this PR.

msooseth and others added 3 commits February 10, 2026 14:49
Co-authored-by: blishko <blishko@argot.org>
Co-authored-by: blishko <blishko@argot.org>
@msooseth msooseth changed the title Add 2 more Expr simplifications related to negative numbers Add 2 more Expr simplifications related to negative numbers, enable NOT concretization Feb 10, 2026
Copy link
Collaborator

@blishko blishko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@msooseth msooseth closed this Feb 10, 2026
@msooseth msooseth deleted the more-expr-simp branch February 10, 2026 14:50
@msooseth msooseth restored the more-expr-simp branch February 10, 2026 14:51
@msooseth msooseth reopened this Feb 10, 2026
@msooseth msooseth merged commit b0e7e9f into main Feb 10, 2026
13 of 16 checks passed
@msooseth msooseth deleted the more-expr-simp branch February 10, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants